<template>
	<view class="app-container">
		<u-input placeholder="请输入昵称" clearable v-model="value"></u-input>
	</view>
</template>

<script>
	import {
		editNickName,
		getUserInfo
	} from '@/api/api.js'
	export default {
		data() {
			return {
				value: ''
			}
		},
		onNavigationBarButtonTap(btn) {
			switch (btn.index) {
				case 0:
					uni.showLoading({
						mask: true
					})
					editNickName({
						nickName: this.value
					}).then((res) => {
						if (res.code === 10000) {
							this.$store.dispatch('userInfo')
							uni.showToast({
								icon: 'success',
								title: '修改成功',
								success() {
									setTimeout(() => {
										uni.switchTab({
											url: '/pages/me/me'
										})

									}, 1000)
								}
							})
						}
					})
					break
			}
		}
	}
</script>

<style lang="scss"></style>
